<?php
use app\Tools\UrlTool;
use app\Tools\StaticTool;
// 引入Js文件
StaticTool::registerJs('admin/user.js', app\assets\LayuiAsset::className());
?>
<fieldset class="layui-elem-field layui-field-title">
    <legend>用户管理 - <?=isset($info['id']) ? '编辑用户' : '添加用户'?></legend>
</fieldset>
<form class="layui-form" action="">
    <input type="hidden" name="id" value="<?=$info ? $info['id'] : ''?>">
    <div class="layui-form-item">
        <label class="layui-form-label">用户名</label>
        <div class="layui-input-block">
            <input type="text" name="name" autocomplete="off" placeholder="请输入用户名" class="layui-input" value="<?=$info ? $info['name'] : ''?>">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">邮箱</label>
        <div class="layui-input-block">
            <input type="text" name="email" autocomplete="off" placeholder="请输入邮箱" class="layui-input" value="<?=$info? $info['email'] : ''?>">
        </div>
    </div>

    <?php if (!empty($roleList)): ?>
    <div class="layui-form-item" pane="">
        <label class="layui-form-label">所属角色</label>
        <div class="layui-input-block">
            <?php foreach ($roleList as $role_id => $roleName): ?>
            <input type="checkbox" name="role_ids[]" lay-skin="primary" title="<?=$roleName?>" value="<?=$role_id?>"
                   <?php if(in_array($role_id, $related_role_ids)): ?> checked <?php endif; ?>
            ><br>
            <?php endforeach; ?>
        </div>
    </div>
    <?php endif; ?>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="button" class="layui-btn layui-btn-sm" id="btn-submit">立即提交</button>
            <a class="layui-btn layui-btn-sm" href="<?= UrlTool::createUrl('/admin/user') ?>">返回</a>
        </div>
    </div>
</form>